﻿

    /**
 * 打开添加元素的提示对话框
 *  modalId 待打开的会话模态框的 id
 * itemId 待添加的数据元素的 Id
 *  message 提示信息
 *  creatUrlString 后端执行添加操作的 Url
 *  defaultUrlString 执行添加操作以后，返回的缺省页面对应的 action 路径
 * mainWorkPlaceAreaId 主显示区 div 的 id
 */


    function appOpenDeleteItemModalForS(modalId, itemId, message, userAddTaskListUrlString, defaultUrlString, mainWorkPlaceAreaId) {
        $('#' + modalId).modal({
            show: true,
            backdrop: 'static'
        });
        document.getElementById("deleteModalMessage").innerHTML = message;
        $('#businessObjectID').val(itemId);
        $('#deleteUrlString').val(userAddTaskListUrlString);
        $('#defaultUrlString').val(defaultUrlString);
        $('#mainWorkPlaceAreaId').val(mainWorkPlaceAreaId);
        document.getElementById("deleteModalErrMessage").innerText = '';
    }



    /*
     * 对于列表元素执行实际的删除
     */
    function appGotoDeletePaginateBoForS() {
        var boVMID = $('#businessObjectID').val();
        var deleteUrl = $('#deleteUrlString').val();
        var urlString = $('#defaultUrlString').val();
        var mainWorkPlaceAreaId = $('#mainWorkPlaceAreaId').val();
        $.ajax({
        cache: false,
            type: 'get',
            async: true,
            url: deleteUrl + boVMID,
            beforeSend: function () {
    }
        }).done(function (delStatus) {
            if (delStatus.deleteSatus === true) {
        $('#deleteItemModal').modal('hide');
                // 刷新列表页
                appGotoDefaultPaginatePageForS(urlString, mainWorkPlaceAreaId);
            } else {
        document.getElementById("deleteModalErrMessage").innerText = delStatus.message;
            }
        }).fail(function () {
        alert("连接后台失败！");
        }).always(function () {
    });
    }


    /*
 * 提取数据列表相关的参数，构成分页器数据，以 json 后向后端提交
 *  urlString 后台 action 路径
 *  mainWorkPlaceAreaId 主显示区域 Div 的 id
 */
    function appGotoDefaultPaginatePageForS(urlString, mainWorkPlaceAreaId) {

        $.ajax({
            cache: false,
            type: "get",
            async: true,
            url: urlString,
            data:
                beforeSend: function () {
        document.getElementById(mainWorkPlaceAreaId).innerHTML = "<p style='margin-top:80px;' align='center'> <i class='fa fa-spinner fa-pulse fa-2x'></i></p>" +
        "<p style='margin-top:20px;' align='center'>  数据加载中，请稍候...</p>";
        }
    }).done(function (data) {
        document.getElementById(mainWorkPlaceAreaId).innerHTML = data;
        resetDivHeight();
        //appinitialCommonListContainer();
        //initialPurchaserCommoditySearchList();

    }).fail(function (jqXHR, textStatus, errorThrown) {
        // 调试时候观察错误
        console.error("调试错误:" + errorThrown);
    }).always(function () {
    });
}


